from datetime import datetime

from django.db import models
from django.contrib.auth.models import AbstractUser


# Create your models here.


class UserProfile(AbstractUser):
    """
    用户
    """
    nickname = models.CharField(max_length=30, null=True, blank=True, verbose_name="昵称")
    birthday = models.DateField(null=True, blank=True, verbose_name="出生年月")
    gender = models.CharField(max_length=6, choices=(("male", u"男"), ("female", "女")), default="female",
                              verbose_name="性别")
    mobile = models.CharField(null=True, blank=True, max_length=11, verbose_name="电话")
    email = models.EmailField(max_length=100, null=True, blank=True, verbose_name="邮箱")
    height = models.FloatField(default=0, verbose_name="身高")
    weight = models.FloatField(default=0, verbose_name="体重")
    nationality = models.CharField(null=True, blank=True, max_length=11, verbose_name="民族")
    marriage_status = models.IntegerField(choices=((1, u"单身"), (2, "离异")), default=1,
                                          verbose_name="婚姻状况")
    work_area_name = models.CharField(null=True, blank=True, max_length=100, verbose_name="工作地")
    born_area_name = models.CharField(null=True, blank=True, max_length=100, verbose_name="出生地")
    career = models.CharField(null=True, blank=True, max_length=100, verbose_name="职业")
    income = models.FloatField(default=0, verbose_name="年收入")
    birth_index = models.IntegerField(choices=((1, u"老大"), (2, "老二"), (3, "老三")), default=1,
                                      verbose_name="家中排行")
    has_children = models.IntegerField(choices=((1, u"没有"), (2, "有")), default=1,
                                       verbose_name="是否有小孩")
    has_car = models.IntegerField(choices=((1, u"没有"), (2, "有")), default=1,
                                  verbose_name="是否有车")
    has_house = models.IntegerField(choices=((1, u"没有"), (2, "有")), default=1,
                                    verbose_name="是否有房")
    relationship_desc = models.CharField(null=True, blank=True, max_length=100, verbose_name="情感经历")
    mate_preference = models.CharField(null=True, blank=True, max_length=100, verbose_name="择偶标准")
    person_intro = models.CharField(null=True, blank=True, max_length=100, verbose_name="个人简介")


class Meta:
    verbose_name = "用户个人信息"
    verbose_name_plural = verbose_name


def __str__(self):
    return self.username


class VerifyCode(models.Model):
    """
    短信验证码
    """
    code = models.CharField(max_length=10, verbose_name="验证码")
    mobile = models.CharField(max_length=11, verbose_name="电话")
    add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间")

    class Meta:
        verbose_name = "短信验证码"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.code
